package com.dragon.modules.yuegou.client.wechat_mini.common;

import com.dragon.modules.yuegou.web.Check;

/**
 * 微信小程序账号配置
 * 
 * @author liuwu
 * @date 2017年12月25日
 *
 */
public class MiniConfig implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private final String appid;

	private final String secret;

	public MiniConfig(String appid, String secret) {
		super();
		Check.notEmpty(appid, "appid is required");
		Check.notEmpty(secret, "secret is required");
		this.appid = appid;
		this.secret = secret;
	}

	/**
	 * @return the appid
	 */
	public String getAppid() {
		return appid;
	}

	/**
	 * @return the secret
	 */
	public String getSecret() {
		return secret;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((appid == null) ? 0 : appid.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		MiniConfig other = (MiniConfig) obj;
		if (appid == null) {
			if (other.appid != null) {
				return false;
			}
		} else if (!appid.equals(other.appid)) {
			return false;
		}
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Brand [");
		if (appid != null) {
			builder.append("appid=");
			builder.append(appid);
			builder.append(", ");
		}
		if (secret != null) {
			builder.append("secret=***********");
		}
		builder.append("]");
		return builder.toString();
	}

}
